import { DtoOmitType, classDto2Zod, formatDate } from "src/utils";
import { CodeErrorDto } from "../dto";
import { ApiProp } from "src/decorator/swagger";
import { z } from "zod";

/** 代码异常记录 */
export class CodeErrorVo extends DtoOmitType(CodeErrorDto, [
  'createTime', 'updateTime',
]) {
  @ApiProp({ desc: '创建时间', default: '2023-12-30 13:20:45', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? formatDate(date) : date)
  })
  createTime!: string

  @ApiProp({ desc: '更新时间', default: '2023-12-30 13:20:45', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? formatDate(date) : date)
  })
  updateTime!: string

  @ApiProp({ desc: "错误信息" })
  message!:  string
}

/** 代码异常记录 */
export const CodeErrorVoZod = classDto2Zod(CodeErrorVo);